package com.rpcdemo.controller;

import com.rpcdemo.client.CnBlogClient;
import com.rpcdemo.client.GithubClient2;
import com.rpcdemo.client.ProductClientService;
import com.rpcdemo.entity.Contributor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * create by yongli on 2022-06-01 16:48
 */
@RequestMapping("feign")
@RestController
public class FeignController {
    @Autowired
    CnBlogClient cnBlogClient;
    @Autowired
    ProductClientService productService;
    @Autowired
    GithubClient2 githubClient2;


    @GetMapping("/blog")
    public String blog(@RequestParam("index") String index) {
        return cnBlogClient.queryProductByIds(index);
    }

    @GetMapping("/product")
    public String product(@RequestParam("index") String index) {
        return productService.queryProductByIds(index);
    }

    @GetMapping("/github")
    public List<Contributor> github(@RequestParam("owner") String owner, @RequestParam("repo") String repo) {
        return githubClient2.contributors(owner, repo);
    }
}
